package util;

import grabber.GSMSetGrabber;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

import java.io.File;
import java.io.IOException;

/**
 * User: Vladimir
 * Date: 21.10.12 Time: 18:37
 */
public class PriceProcessor {
    public static void main(String[] args) throws BiffException, IOException {
        String path = "G:\\projects\\my-im-tools\\data\\price\\apple_accs.xls";
        Workbook workbook = Workbook.getWorkbook(new File(path));
        Sheet sheet = workbook.getSheet(0);
        for (int row = 0; row < sheet.getRows(); row++) {
            String name = sheet.getCell(1, row).getContents();
            if (name.length() < 2) continue;
            name = filterName(name);
            System.out.println(name);
        }
        for (int row = 0; row < sheet.getRows(); row++) {
            String priceStr = sheet.getCell(3, row).getContents();
            try {
                int price = Integer.parseInt(priceStr);
                System.out.println(price);
            } catch (NumberFormatException e) {
//                continue;
            }
        }
    }

    private static String filterName(String name) {
        name = name.replace("Доп.", "Дополнительный");
        name = name.replace("Li1450", "");
        name = name.replace("2,1 A", "");
        name = name.replace("Без упаковки", "");
        name = name.replace("Чехол/книжка", "Чехол книжка");
        name = name.replace("DR02-IPA", "");
        name = GSMSetGrabber.filterTextInBrackets(name);
        name = name.trim();
        return name;
    }
}
